package com.tiny.diamond.internal.mapping;

import com.tiny.diamond.DiamondApiException;
import com.tiny.diamond.DiamondRequest;
import com.tiny.diamond.DiamondResponse;
import com.tiny.diamond.SignItem;

/**
 * 动态格式转换器。
 *
 * @author carver.gu
 * @since 1.0, Apr 11, 2010
 */
public interface Converter {

    /**
     * 把字符串转换为响应对象。
     *
     * @param <T>   领域泛型
     * @param rsp   响应字符串
     * @param clazz 领域类型
     * @return 响应对象
     * @throws DiamondApiException
     */
    <T extends DiamondResponse> T toResponse(String rsp, Class<T> clazz) throws DiamondApiException;

    /**
     * 获取响应内的签名数据
     *
     * @param request
     * @param responseBody
     * @return
     * @throws DiamondApiException
     */
    SignItem getSignItem(DiamondRequest<?> request, String responseBody) throws DiamondApiException;

    /**
     *  获取解密后的响应内的真实内容
     *
     * @param request
     * @param body
     * @param format
     * @param encryptType
     * @param encryptKey
     * @param charset
     * @return
     * @throws DiamondApiException
     */
    String encryptSourceData(DiamondRequest<?> request, String body, String format,String encryptType, String encryptKey, String charset) throws DiamondApiException;
}
